package com.zmy.xcx.config;

import com.zmy.xcx.interceptor.JwtTokenWxUserInterceptor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Component
@Slf4j
@RequiredArgsConstructor
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
    private final JwtTokenWxUserInterceptor jwtTokenWxUserInterceptor;
    /**
     * 注册自定义拦截器
     * @param registry
     */
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        log.info("开始注册自定义拦截器...");
        registry.addInterceptor(jwtTokenWxUserInterceptor)
                //拦截所有 /api请求
                .addPathPatterns("/api/**")
                //不拦截登录接口
                .excludePathPatterns("/api/user/login")
                .order(1);
    }

}
